﻿<Window x:Class="MVVM.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:MVVM" xmlns:Birthday="clr-namespace:MVVM.Birthday" Title="MainWindow" Height="136" Width="313">
    <Window.Resources>
        <Birthday:PersonViewModel x:Key="man" Age="18" Name="Cheka"/>
        <Thickness x:Key="margin" Left="3" Top="3" Right="3" Bottom="3"/>
        <Style TargetType="Label">
            <Setter Property="HorizontalContentAlignment" Value="Right"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Margin" Value="{StaticResource margin}"/>
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="IsEnabled" Value="false"/>
            <Setter Property="Margin" Value="{StaticResource margin}"/>
        </Style>
        <Style TargetType="Button">
            <Setter Property="Margin" Value="{StaticResource margin}"/>
        </Style>
    </Window.Resources>
    <Grid DataContext="{StaticResource man}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1.5*" />
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="2*" />
        </Grid.ColumnDefinitions>
        <Label Grid.Row="0" Grid.Column="0" Content="Name:" />
        <Label Grid.Row="1" Grid.Column="0" Content="Age:" />
        <TextBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2"  Text="{Binding Path=Name}"/>
        <TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"  Text="{Binding Path=Age}"/>
        <!--note: binding command to control, then code-behind files becomes unnecessary-->
        <Button Content="Birthday" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" 
                Command="{Binding Path=AgeAddCommand}"/>
    </Grid>
</Window>
